package com.szosen.util;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class BackGroundThread implements Runnable {
	BackGroundTask task;

	public static ExecutorService exec = Executors.newFixedThreadPool(10);

	public BackGroundThread(BackGroundTask task) {
		this.task = task;
	}

	public interface BackGroundTask {
		public void process();
	}

	@Override
	public void run() {
		task.process();
	}

	public void start() {
		exec.execute(this);
	}

	/***
	 * 执行新的runnable线程
	 * 
	 * @param command
	 */
	public void execute(Runnable command) {
		exec.execute(command);
	}
	/***
	 * 停止所有的后台上传的任务。
	 */
	public static void stopAll() {
//		exec.shutdownNow();
	}
}
